const router = require('koa-router')()
const { query, escape } = require('../../db/mysql')

router.prefix('/users')

// 动态域名 http://localhost:3000/users/mode/1231
// 动态域名不能用async-validator校验
router.get('/mode/:id', async (ctx, next) => {
  console.log(ctx.query)
  // const { data, error } = await validator(ctx, modeRules)
  // console.log({ data, error })
  const res = ctx.params // { id: 1231 }
  // console.log(Schema)
  ctx.body = res
})

// 获取列表
router.post('/list', async (ctx, next) => {
  const sql = 'select * from database_01.users'
  const res = await query(sql)
  ctx.body = res
})

module.exports = router
